import 'package:flutter/material.dart';
import 'package:oktoast/oktoast.dart';

///
/// SingleChildScrollView
/// SingleChildScrollView类似于Android中的ScrollView，它只能接收一个子组件，定义如下：
///https://api.flutter-io.cn/flutter/widgets/SingleChildScrollView-class.html
///
///
///  Scrollbar 滑动条
///
/// ListTile  横向布局
/// https://api.flutter-io.cn/flutter/material/ListTile-class.html
///
///
class SingleChildScrollViewPage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Scaffold(
        appBar: AppBar(
          title: Text("SingleChildScrollView"),
        ),
        body: getSingleChildScrollView02(),
    );
  }
}

getSingleChildScrollView() {
  List<Widget> child = [];
  for(int index= 0;index<20;index++){
    child.add(ListTile(
      leading: Icon(Icons.person),
      title: Text("序号：${index+1}"),
      onTap: (){
        showToast("点击序号${index}");
      },
    ));
    child.add(Divider(
      color: Colors.black12,
      height: 1,
    ));

  }
  return SingleChildScrollView(
      padding: EdgeInsets.all(8.0),
      child: Center(
        child: Column(
          children: child,
        ),
      ),
  );
}



getSingleChildScrollView02() {
  List<Widget> child = [];
  for(int index= 0;index<20;index++){
    child.add(ListTile(
      leading: Icon(Icons.person),
      title: Text("序号：${index+1}"),
      onTap: (){
        showToast("点击序号${index}");
      },
    ));
    child.add(Divider(
      color: Colors.black12,
      height: 1,
    ));
  }
  return Scrollbar(child: SingleChildScrollView(
    padding: EdgeInsets.all(8.0),
    child: Center(
      child: Column(
        children: child,
      ),
    ),
  ));
}